$(function () {
    var code = location.search.split('?code=').pop().split('&state=')[0];
    if (!code) {
        BASE.clearpop('未获取到Code');
        return;
    }
    BASE.getHttp('/device/member/wxLogin', {code: code}, function (res) {
        if(res.ecode ==='MEMBER_NOREGISTER_EXCEPTION'){ /*新的用户*/
            location.href = '/bindOldAccountToweixin.html?access_token='+res.data.accessToken+'&openId='+res.data.openId;
            return;
        }
        if(res.code !== 200 && res.ecode !=='MEMBER_NOREGISTER_EXCEPTION'){
            BASE.clearpop(res.message||'授权登录失败');
            return;
        }
        BASE.LOGIN.loginSuccess(res);
    })
});
